package com.cqjtu.platform.shiro;

import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.session.Session;
import org.apache.shiro.session.SessionListener;

import java.util.concurrent.atomic.AtomicInteger;

/**
 *
 * @author pengyangyan
 */
@Slf4j
public class ShiroSessionListener implements SessionListener {

    private final AtomicInteger sessionCount = new AtomicInteger(0);

    @Override
    public void onStart(Session session) {
        sessionCount.incrementAndGet();
        log.info("在线人数：",sessionCount);

    }

    @Override
    public void onStop(Session session) {
        sessionCount.decrementAndGet();
        log.info("在线人数：",sessionCount);

    }

    @Override
    public void onExpiration(Session session) {
        sessionCount.decrementAndGet();
        log.info("在线人数：",sessionCount);
    }
}

